package com.ruoyi.complex.controller;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.complex.domain.ComplexItem;
import com.ruoyi.complex.service.IComplexItemService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;

/**
 * 综测加减分具体项目Controller
 * 
 * @author wky
 * @date 2024-04-25
 */
@RestController
@RequestMapping("/complex/item")
@Tag(name = "【综测加减分具体项目】管理")
public class ComplexItemController extends BaseController
{
    @Autowired
    private IComplexItemService complexItemService;

    /**
     * 查询综测加减分具体项目列表
     */
    @Operation(summary = "查询综测加减分具体项目列表")
    @PreAuthorize("@ss.hasPermi('complex:item:list')")
    @GetMapping("/list")
    public TableDataInfo list(ComplexItem complexItem)
    {
        startPage();
        List<ComplexItem> list = complexItemService.selectComplexItemList(complexItem);
        return getDataTable(list);
    }

    /**
     * 导出综测加减分具体项目列表
     */
    @Operation(summary = "导出综测加减分具体项目列表")
    @PreAuthorize("@ss.hasPermi('complex:item:export')")
    @Log(title = "综测加减分具体项目", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ComplexItem complexItem)
    {
        List<ComplexItem> list = complexItemService.selectComplexItemList(complexItem);
        ExcelUtil<ComplexItem> util = new ExcelUtil<ComplexItem>(ComplexItem.class);
        util.exportExcel(response, list, "综测加减分具体项目数据");
    }

    /**
     * 获取综测加减分具体项目详细信息
     */
    @Operation(summary = "获取综测加减分具体项目详细信息")
    @PreAuthorize("@ss.hasPermi('complex:item:query')")
    @GetMapping(value = "/{itemId}")
    public AjaxResult getInfo(@PathVariable("itemId") Long itemId)
    {
        return success(complexItemService.selectComplexItemByItemId(itemId));
    }

    /**
     * 新增综测加减分具体项目
     */
    @Operation(summary = "新增综测加减分具体项目")
    @PreAuthorize("@ss.hasPermi('complex:item:add')")
    @Log(title = "综测加减分具体项目", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ComplexItem complexItem)
    {
        return toAjax(complexItemService.insertComplexItem(complexItem));
    }

    /**
     * 修改综测加减分具体项目
     */
    @Operation(summary = "修改综测加减分具体项目")
    @PreAuthorize("@ss.hasPermi('complex:item:edit')")
    @Log(title = "综测加减分具体项目", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ComplexItem complexItem)
    {
        return toAjax(complexItemService.updateComplexItem(complexItem));
    }

    /**
     * 删除综测加减分具体项目
     */
    @Operation(summary = "删除综测加减分具体项目")
    @PreAuthorize("@ss.hasPermi('complex:item:remove')")
    @Log(title = "综测加减分具体项目", businessType = BusinessType.DELETE)
	@DeleteMapping("/{itemIds}")
    public AjaxResult remove(@PathVariable( name = "itemIds" ) Long[] itemIds) 
    {
        return toAjax(complexItemService.deleteComplexItemByItemIds(itemIds));
    }
}
